package main

import (
	"fmt"
	"time"

	workerpool "github.com/robin/workerpool"
)

func main() {
	p := workerpool.New(
		5,
		workerpool.WithAllocWorkers(false),
		workerpool.WithBlock(false))

	time.Sleep(2 * time.Second)

	for i := 0; i < 10; i++ {
		err := p.Schedule(func() {
			// fmt.Printf("worker [%03d] start\n", i)
			time.Sleep(5 * time.Second)
		})

		if err != nil {
			fmt.Println("task:", i, "err:", err)
		}

	}

	p.Free()
}
